package video.dali.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import video.dali.common.PageResult;
import video.dali.common.dto.CategoryPageDto;
import video.dali.common.entity.Category;
import video.dali.mapper.CategoryMapper;
import video.dali.service.CategoryService;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * 查询所有视频分类
     * @param categoryPageDto
     * @return
     */
    @Override
    public PageResult listAllCategoryPage(CategoryPageDto categoryPageDto) {
        PageHelper.startPage(categoryPageDto.getPage(),categoryPageDto.getPageSize());
        Page<Category> page = categoryMapper.list(categoryPageDto);
        System.out.println("Total = "+page.getTotal());
        return new PageResult(page.getTotal(),page.getResult());
    }
}
